An affinity mask is a bit mask indicating what processor(s) a thread or process should be run on by the scheduler of an operating system. Setting the affinity mask for certain processes running under Windows can be useful as there are several system processes (especially on domain controllers) that are restricted to the first CPU / Core. So, excluding the first CPU might lead to better application performance.
#include#include // Set OpenMP thread affinity void set_thread_affinity () { #pragma omp parallel default(shared) { DWORD_PTR mask = (DWORD_PTR )1 << omp_get_thread_num(); SetThreadAffinityMask(GetCurrentThread(), mask); } }
|
|